﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Web.Utility;

namespace DddCms.Models.UIComponent.Form
{
    public class FormRowViewModelBuilder
    {
        public FormRowViewModel FormRowViewModel { get; set; }

        public FormRowViewModelBuilder()
        {
            FormRowViewModel = new FormRowViewModel();
        }
        
        public FormRowViewModelBuilder AddField(EditItem value)
        {
            FormFieldViewModel info = new FormFieldViewModel();
            info.FormField = FormField.Text;
            info.Title = value.Display.ToHtmlString();
            info.EditItem = value;

            FormRowViewModel.Fields.Add(info);
            return this;
        }
        public FormRowViewModelBuilder AddField(string title, EditItem value)
        {
            FormFieldViewModel info = new FormFieldViewModel();
            info.FormField = FormField.Text;
            info.Title = title;
            info.EditItem = value;

            FormRowViewModel.Fields.Add(info);
            return this;
        }

        public FormRowViewModelBuilder AddFieldCheck(string title, EditItem value)
        {
            FormFieldViewModel info = new FormFieldViewModel();
            info.FormField = FormField.Checkbox;
            info.Title = title;
            info.EditItem = value;

            FormRowViewModel.Fields.Add(info);
            return this;
        }


    }
}